package com.qingke.easyjava.jdbc.command;

import java.util.HashMap;
import java.util.Map;

import com.qingke.easyjava.jdbc.command.impl.ExitCommand;
import com.qingke.easyjava.jdbc.command.impl.HelpCommand;
import com.qingke.easyjava.jdbc.command.impl.LoginCommand;
import com.qingke.easyjava.jdbc.command.impl.SignupCommand;

//命令分类
public class SystemCommandFactory extends CommandFactory{
	
	private static Map<CommandCode,Command> commandMap = new HashMap<>();
	
	static { //静态代码块在类加载的时候进行一些静态操作
		commandMap.put(CommandCode.EXIT, new ExitCommand());
		commandMap.put(CommandCode.HELP, new HelpCommand());
		commandMap.put(CommandCode.SIGNUP, new SignupCommand());
		commandMap.put(CommandCode.LOGIN, new LoginCommand());
	}
	
	public Command buildCommand(CommandCode cmd) {
		Command command = commandMap.get(cmd);
		
		return command;
	}

}
